﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using CitizenJournalismNetworkServer.Utility;
using CitizenJournalismNetworkServer.Enumerations;

namespace CitizenJournalismNetworkServer.Controllers
{
    public class OutputTypedController: Controller
    {
        private JavaScriptSerializer _serializer;

        public OutputTypedController()
            : base()
        {
            _serializer = new JavaScriptSerializer();
            _serializer.RegisterConverters(new List<EFObjectConverter> { new EFObjectConverter(2) });
        }

        [Authorize(Roles="Administrator")]
        protected ActionResult GenerateResult(object outputModel, string outputType)
        {
            return View(outputModel);
            /*+++ May no longer be necessary!
            switch (outputType)
            {
                case ContentTypeConstants.Json:
                    return new ContentResult()
                    {
                        Content = _serializer.Serialize(outputModel),
                        ContentType = "application/json"
                    };
                case ContentTypeConstants.Atom:
                    throw new NotImplementedException();
                default:
                    return View(outputModel);
            }
             */
        }

    }
}